package common.fengkai.filepost.controller;

import com.github.pagehelper.PageHelper;
import common.fengkai.filepost.VO.R;
import common.fengkai.filepost.annotation.AroundAnnotation;
import common.fengkai.filepost.annotation.LogAnnotation;
import common.fengkai.filepost.annotation.PermissionsAnnotation;
import common.fengkai.filepost.bean.mysqlBean.EmpUser;
import common.fengkai.filepost.bean.mysqlBean.RequestLogEntity;
import common.fengkai.filepost.common.interfaces.impl.RequestLogConvertImpl;
import common.fengkai.filepost.dao.mysqldao.EmpUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Fengkai
 * @creat 2022/9/23
 */
@Slf4j
@RestController
@RequestMapping("/emp")
public class EmpConroller {

    @Autowired
    private EmpUserMapper empUserMapper;

    @PostMapping("/list")
    public R getListUser(@RequestBody EmpUser empUser){
        EmpUser empUsers = empUserMapper.selectByPrimaryKey(empUser.getId());
        Map<String,Object > objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("list", empUsers);
        return R.ok(objectObjectHashMap);
    }

    @PostMapping("/get")
    @PermissionsAnnotation
    public R get(@RequestBody EmpUser empUser){
        EmpUser empUsers = empUserMapper.selectByPrimaryKey(empUser.getId());
        Map<String,Object > objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("list", empUsers);
        return R.ok(objectObjectHashMap);
    }

    @PostMapping("/getAround")
//    @AroundAnnotation
    @LogAnnotation(desc = "根据id获取用户信息" ,convter = RequestLogConvertImpl.class)
    public R getAround(@RequestBody EmpUser empUser){
        EmpUser empUsers = empUserMapper.selectByPrimaryKey(empUser.getId());
        Map<String,Object > objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("list", empUsers);
        return R.ok(objectObjectHashMap);
    }
}
